home *** CD-ROM | disk | FTP | other *** search
/ User's Choice Windows CD / User's Choice Windows CD (CMS Software)(1993).iso / misc1 / iv26_w30.zip / EXAMPLES / IDRAW / IPOLYGON.C < prev    next >
C/C++ Source or Header  |  1991-12-21  |  4KB  |  107 lines

  1. /*
  2.  * Copyright (c) 1987, 1988, 1989 Stanford University
  3.  *
  4.  * Permission to use, copy, modify, distribute, and sell this software and its
  5.  * documentation for any purpose is hereby granted without fee, provided
  6.  * that the above copyright notice appear in all copies and that both that
  7.  * copyright notice and this permission notice appear in supporting
  8.  * documentation, and that the name of Stanford not be used in advertising or
  9.  * publicity pertaining to distribution of the software without specific,
  10.  * written prior permission.  Stanford makes no representations about
  11.  * the suitability of this software for any purpose.  It is provided "as is"
  12.  * without express or implied warranty.
  13.  *
  14.  * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  15.  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
  16.  * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  17.  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  18.  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  19.  * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
  20.  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  21.  */
  22.  
  23. // $Header: ipolygons.c,v 1.7 89/10/09 14:48:22 linton Exp $
  24. // implements classes IFillRect and IFillPolygon.
  25.  
  26. #include "ipaint.h"
  27. #include "ipolygons.h"
  28.  
  29. // IFillRect passes its arguments to FillRect.
  30.  
  31. IFillRect::IFillRect (Coord x0, Coord y0, Coord x1, Coord y1, Graphic* gs)
  32. : (x0, y0, x1, y1, gs) {
  33. }
  34.  
  35. // contains returns true if the IFillRect contains the given point
  36. // unless the pattern is the "none" pattern.
  37.  
  38. boolean IFillRect::contains (PointObj& po, Graphic* gs) {
  39.     boolean contains = false;
  40.     IPattern* pattern = (IPattern*) gs->GetPattern();
  41.     if (!pattern->None()) {
  42.     contains = GFillRect::contains(po, gs);
  43.     }
  44.     return contains;
  45. }
  46.  
  47. // intersects returns true if the IFillRect intersects the given box
  48. // unless the pattern is the "none" pattern.
  49.  
  50. boolean IFillRect::intersects (BoxObj& userb, Graphic* gs) {
  51.     boolean intersects = false;
  52.     IPattern* pattern = (IPattern*) gs->GetPattern();
  53.     if (!pattern->None()) {
  54.     intersects = GFillRect::intersects(userb, gs);
  55.     }
  56.     return intersects;
  57. }
  58.  
  59. // draw draws the IFillRect unless the pattern is the "none" pattern.
  60.  
  61. void IFillRect::draw (Canvas* c, Graphic* gs) {
  62.     IPattern* pattern = (IPattern*) gs->GetPattern();
  63.     if (!pattern->None()) {
  64.     GFillRect::draw(c, gs);
  65.     }
  66. }
  67.  
  68. // IFillPolygon passes its arguments to FillPolygon.
  69.  
  70. IFillPolygon::IFillPolygon (Coord* x, Coord* y, int n, Graphic* gs)
  71. : (x, y, n, gs) {
  72. }
  73.  
  74. // contains returns true if the IFillPolygon contains the given point
  75. // unless the pattern is the "none" pattern.
  76.  
  77. boolean IFillPolygon::contains (PointObj& po, Graphic* gs) {
  78.     boolean contains = false;
  79.     IPattern* pattern = (IPattern*) gs->GetPattern();
  80.     if (!pattern->None()) {
  81.     contains = FillPolygon::contains(po, gs);
  82.     }
  83.     return contains;
  84. }
  85.  
  86. // intersects returns true if the IFillPolygon intersects the given
  87. // box unless the pattern is the "none" pattern.
  88.  
  89. boolean IFillPolygon::intersects (BoxObj& userb, Graphic* gs) {
  90.     boolean intersects = false;
  91.     IPattern* pattern = (IPattern*) gs->GetPattern();
  92.     if (!pattern->None()) {
  93.     intersects = FillPolygon::intersects(userb, gs);
  94.     }
  95.     return intersects;
  96. }
  97.  
  98. // draw draws the IFillPolygon unless the pattern is the "none"
  99. // pattern.
  100.  
  101. void IFillPolygon::draw (Canvas* c, Graphic* gs) {
  102.     IPattern* pattern = (IPattern*) gs->GetPattern();
  103.     if (!pattern->None()) {
  104.     FillPolygon::draw(c, gs);
  105.     }
  106. }
  107.